package com.sgb.kjwl.view.ui.adapter.shopping;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.ShoppingCarEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.StringUtil;

import java.util.List;

public class CheckOrderAdapter extends BaseRecycleAdapter<ShoppingCarEntity.DataBean> {

    private Context context;
    private TextView tvTitle;
    private ImageView ivImg;
    private TextView tvNum;
    private TextView tvPrice;

    public CheckOrderAdapter(Context context, List<ShoppingCarEntity.DataBean> datas) {
        super(context, R.layout.item_check_order, datas);
        this.context = context;
    }

    @Override
    public void convert(ItemViewHolder holder, final ShoppingCarEntity.DataBean entity) {
        holder.setBinding(BR.viewModel, entity);
        tvTitle = holder.getItem().findViewById(R.id.tv_title);
        ivImg = holder.getItem().findViewById(R.id.iv_img);
        tvNum = holder.getItem().findViewById(R.id.tv_num);
        tvPrice = holder.getItem().findViewById(R.id.tv_price);

        tvTitle.setText(entity.getCartTitle());
        tvNum.setText("x"+(entity.getItemNum()/1000));
        tvPrice.setText("￥"+ StringUtil.showPrice(entity.getPrice())+"/"+entity.getUnit());
        Glide.with(context).load(entity.getImageUrls().get(0)).into(ivImg);
    }

   /* private CheckOrderListAdapter.onEditClickListener editClickListener;

    public void setonEditClick(CheckOrderListAdapter.onEditClickListener editClickListener) {
        this.editClickListener = editClickListener;
    }

    public interface onEditClickListener {
        void onCancelClick(String id, int position);
        void onUpClick(String id, int position);
        void onEditeClick(String id, int position);
    }*/
}
